package com.example.huhu.chd4_01;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Activity2 extends AppCompatActivity {
    Button button_back;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_2);
        button_back = (Button) findViewById(R.id.button_back);
        button_back.setOnClickListener(new ButtonClickListener());
    }
    class ButtonClickListener implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            //新建一个ｉｎｔｅｎｔ对象，并指定启动程序MainActivity
            Intent myintent = new Intent();
            myintent.setClass(Activity2.this, MainActivity.class);
            Activity2.this.startActivity(myintent);
            Activity2.this.finish();


        }
    }
}
